package com.cgt.ssm.controller;

import com.cgt.ssm.pojo.Student;
import com.cgt.ssm.service.IStudentService;
import com.cgt.ssm.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/student")
public class StudentController {
	@Autowired
	private IStudentService studentService;

	@RequestMapping("/selectAll")
	@ResponseBody
	public List<Student> selectAll(){
		System.out.println("StudentController.selectAll");
		List<Student> list = studentService.selectAll();
		return list;
	}

	@RequestMapping("/selectAll3")
	@ResponseBody
	public Result selectAll3() {
		System.out.println("StudentController.selectAll");
		List<Student> list = studentService.selectAll();
		return Result.ok(list);
	}

	@RequestMapping("/selectAll2")
	public String selectAll2(Model model) {
		System.out.println("StudentController.selectAll");
		List<Student> list = studentService.selectAll();
		model.addAttribute("list", list);
		return "/WEB-INF/student_list.jsp";
	}
}
